#ifndef MOVEUPDOWN_H_
#define MOVEUPDOWN_H_

#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <string>
#include "ariba/ariba.h"

using namespace std;
using namespace ariba;
using std::string;

using_serialization;

class MoveUpDown : public Message {
	VSERIALIZEABLE;

public:
	MoveUpDown();
	MoveUpDown(string player);
	MoveUpDown(string player, bool direction, float positionX, float positionY, bool stop, float timestamp);
	virtual ~MoveUpDown();
	bool getDirection() const;
    string getPlayer() const;
    float getPositionX() const;
    float getPositionY() const;
    bool getStop() const;
    float getTimestamp() const;
    void setDirection(bool direction);
    void setPlayer(string player);
    void setPositionX(float positionX);
    void setPositionY(float positionY);
    void setStop(bool stop);
    void setTimestamp(float timestamp);

private:
	string player;
	bool stop;
	bool direction; //1 up; 0 down
	float timestamp;
	float positionX;
	float positionY;
};

sznBeginDefault( MoveUpDown, X ) {
	std::stringstream ss;
	if (X.isSerializer()) {

		boost::archive::text_oarchive oa(ss);
		oa << stop << direction << timestamp << positionX << positionY;
		string s = ss.str();
		uint32_t len = s.length();
		X && T(player) && len && T(s, len);
		//cout<<"Serialize: "<<s<<"\n";

	}else{
		uint32_t len;
		string s;
		X && T(player) && len;
		X && T(s, len);
		ss << s;
		boost::archive::text_iarchive ia(ss);
		ia >> stop >> direction >> timestamp >> positionX >> positionY;
		//cout<<"Deserialize: "<<s<<"\n";
	}
} sznEnd();

#endif /* MOVEUPDOWN_H_ */
